<template>
  <div class="big-box">
    <div class="search-box">
      <div class="city-box" @click="toCityfn">
        <span>{{ city }}</span>
        <van-icon name="arrow-down" color="#7f7f80" />
        <span class="line">|</span>
      </div>
      <van-search placeholder="请输入小区或地址" background="none" />
      <div class="icon-box" @click="toMapfn">
        <van-icon name="map-marked" color="#fff" />
      </div>
    </div>
    <div class="lunbo">
      <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
        <van-swipe-item v-for="item in imglist" :key="item.id">
          <van-image
            width="100%"
            height="100%"
            :src="`http://liufusong.top:8080${item.imgSrc}`"
          />
        </van-swipe-item>
      </van-swipe>
    </div>
    <van-grid :border="false">
      <van-grid-item
        icon=""
        text="整租"
        to="/find"
      ></van-grid-item>
      <van-grid-item
        icon=""
        text="合租"
        to="/find"
      ></van-grid-item>
      <van-grid-item
        icon=""
        text="地图找房"
        to="/map"
      ></van-grid-item>
      <van-grid-item
        icon=""
        text="去租房"
        to="/add"
      ></van-grid-item>
    </van-grid>
    <div class="rentGroup">
      <div class="title">
        <h3>租房小组</h3>
        <!-- <a href="#">更多</a> -->
        <span>更多</span>
      </div>
      <div class="inr">
        <ul>
          <li>
            <img
              src="https://img1.baidu.com/it/u=2081974655,1698118276&fm=253&fmt=auto&app=138&f=JPEG?w=200&h=200"
              alt=""
            />
            <div class="text">
              <p>家住回龙观</p>
              <p>归属的感觉</p>
            </div>
          </li>
          <li>
            <img
              src="https://img2.baidu.com/it/u=2599159827,108601597&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500"
              alt=""
            />
            <div class="text">
              <p>宜居四五环</p>
              <p>大都市生活</p>
            </div>
          </li>
          <li>
            <img
              src="https://img1.baidu.com/it/u=3997904503,2918286285&fm=253&fmt=auto&app=138&f=JPEG?w=640&h=427"
              alt=""
            />
            <div class="text">
              <p>喧嚣三里屯</p>
              <p>繁华的背后</p>
            </div>
          </li>
          <li>
            <img
              src="https://p0.meituan.net/iphoenix/f6a59c85fa32ca0d773ac16e5947408f3407587.jpg%40340w_255h_1e_1c_1l%7Cwatermark%3D0"
              alt=""
            />
            <div class="text">
              <p>比邻十号线</p>
              <p>地铁心连心</p>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import { home } from '@/api/user'
export default {
  data () {
    return {
      imglist: [],
      city: '北京'
    }
  },
  async created () {
    const { body } = await home()
    // console.log(body)
    this.imglist = [...body]
    this.city = localStorage.getItem('cityName')
  },
  methods: {
    toCityfn () {
      this.$router.push('/city')
    },
    toMapfn () {
      this.$router.push('/map')
    }
  }
}
</script>

<style lang="less" scoped>
// *{
//   padding: 0;
//   margin: 0;
// }
.big-box {
  position: relative;
}
.search-box {
  margin: 0 auto;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-43%);
  width: 100%;
  height: 34px;
  z-index: 2;
  .van-search {
    padding-left: 0;
  }
  .van-search__content {
    padding-left: 0;
  }
  .van-search,
  .van-cell {
    background-color: #fff;
  }
  .city-box {
    background-color: #fff;
    height: 34px;
    font-size: 14px;
    line-height: 34px;
    padding-left: 10px;
    // .van-icon {
    //   // margin-right: 10px;
    // }
  }
  .line {
    height: 34px;
    padding: 0 10px;
    font-size: 16px;
    line-height: 34px;
    background-color: #fff;
    color: #ccc;
  }
  .icon-box {
    width: 20px;
    height: 20px;
    padding: 3px;
    text-align: center;
    border: 2px solid #fff;
    border-radius: 50%;
  }
}
.lunbo .my-swipe,
.van-swipe {
  position: relative;
  height: 212px;
}
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  // background-color: #39a9ed;
}
::v-deep .van-grid-item__icon {
  font-size: 60px;
}
::v-deep .van-grid-item__text {
  font-size: 14px;
  color: #333;
}
.rentGroup {
  background-color: #f6f5f6;
}
.title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.title h3 {
  color: #333;
  font-size: 15px;
  margin: 15px 0 15px 20px;
}
.title span {
  color: #787d82;
  font-size: 14px;
  font-weight: 400;
  margin-right: 10px;
}
.inr ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
  align-items: center;
}
.inr ul li {
  width: 45%;
  font-style: 14px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 10px;
  background-color: #fff;
  // height: 50px;
  // background-color: #39a9ed;
}
.inr ul li img {
  width: 50px;
  height: 50px;
  margin: 0 10px;
}
// .inr ul li .text {
//   margin-left: 10px;
// }
.inr ul li .text p {
  margin: 0;
  font-size: 14px;
  color: #333;
}
</style>
